﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using Microsoft.Phone.Data.Linq;
using Microsoft.Phone.Data.Linq.Mapping;
using System.ComponentModel;

namespace DiabitiesWindowsPhoneAPP
{
    public class FoodAndFoodHist
    {
        public Table<Food> food;
        public Table<FoodHist> foodhistory;
    }
        
    [Table]    
    public class Food
    {
        public Food() { }
        public Food(int FoodID, string FoodName, 
                    float ServSize, string ServSizeUnits, 
                    float CalPerServ, float CarbsPerServ, 
                    float ProteinPerServ, float FatPerServ) 
        {
            fid = FoodID;
            foodname = FoodName;
            ss = ServSize;
            ssu = ServSizeUnits;
            calps = CalPerServ;
            carps = CarbsPerServ;
            pps = ProteinPerServ;
            fps = FatPerServ;
        }
        int _fid;
        string _foodname;
        float _ss;
        string _ssu;
        float _calps;
        float _carps;
        float _pps;
        float _fps;
        [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int fid
        {
            get { return _fid; }
            set { _fid = value; }
        }
        [Column]
        public string foodname
        {
            get { return _foodname; }
            set { _foodname = value; }
        }
         [Column]
        public float ss
        {
            get { return _ss; }
            set { _ss = value; }
        }
         [Column]
         public string ssu
         {
             get { return _ssu; }
             set { _ssu = value; }
         }
         [Column]
         public float calps
         {
             get { return _calps; }
             set { _calps = value; }
         }
         [Column]
         public float carps
         {
             get { return _carps; }
             set { _carps = value; }
         }
         [Column]
         public float pps
         {
             get { return _pps; }
             set { _pps = value; }
         }
         [Column]
         public float fps
         {
             get { return _fps; }
             set { _fps = value; }
         }
        
    }
     [Table]
    public class FoodHist
    {
        
        public FoodHist() { }
        public FoodHist(int FHID, int FoodID,
                        DateTime DateTime, float Quantity, 
                        string FHNotes, int PersonID) 
        {
            fhid = FHID;
            datetime = DateTime;
            qty = Quantity;
            fhnotes = FHNotes;           
        }
        int _fhid;
        DateTime _datetime;
        float _qty;
        string _fhnotes;
       
         [Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
        public int fhid
        {
            get { return _fhid; }
            set { _fhid = value; }
        }
         
         [Column]
         public int foodid;
         private EntityRef<Food> _fid;
        [Association(Storage = "_fid", ThisKey = "foodid", IsForeignKey = true)]
         public Food food
        {
            get { return this._fid.Entity; }
            set { this._fid.Entity = value; }
        }
        
         [Column]
        public DateTime datetime
        {
            get { return _datetime; }
            set { _datetime = value; }
        }
         [Column]
         public float qty
         {
             get { return _qty; }
             set { _qty = value; }
         }
         [Column]
         public string fhnotes
         {
             get { return _fhnotes; }
             set { _fhnotes = value; }
         }
         [Column]
         public int pid;
        private EntityRef<Person> _pid;
        [Association(Storage = "_personid", ThisKey = "pid", IsForeignKey = true)]
        public Person person
        {
            get { return this._pid.Entity; }
            set { this._pid.Entity = value; }
        }
    }
}
